<?php

class Admin_IndexController extends Zend_Controller_Action {
	
	protected $academic_year_id;
	/**
	 * @param $academic_year_id the $academic_year_id to set
	 */
	public function setAcademic_year_id($academic_year_id) {
		$this->academic_year_id = $academic_year_id;
	}

	/**
	 * @return the $academic_year_id
	 */
	public function getAcademic_year_id() {
		return $this->academic_year_id;
	}
	
	
	public function init() {
		$auth = Zend_Auth::getInstance ();
		if ($auth->hasIdentity ()) {
			if ($auth->getIdentity ()->role != 'administrator') {
				$this->_helper->redirector ( 'index', 'auth', 'default' );
			}
		} else {
			$this->_helper->redirector ( 'index', 'auth', 'default' );
		}
		$this->_helper->layout->setLayout ( 'admin' );
		$academic = new Zend_Session_Namespace ( 'academic' );
	
		if(isset($academic->id))
		$this->setAcademic_year_id($academic->id);
		/* Initialize action controller here */
	}
	
	
	public function indexAction() {
		$data = $this->view->Action ( 'leftsidebar', 'Index', 'admin' );
		$this->view->leftsidebar = $data;
	}
	
	public function leftsidebarAction() {
		$moAdmission = new Application_Model_Academic ( );
		$aAcademic_list = $moAdmission->fetchAll ();
		$aCurrent_academic = $moAdmission->getCurrentAcademicYearId ();
		$this->view->current_academic_id = $aCurrent_academic ['id'];
		$this->setAcademic_year_id($aCurrent_academic ['id']);
		$this->view->academic_list = $aAcademic_list;
	}
	
	public function saveAction() {
		// action body
	}

}



